package javolution.xml.stream;

import com.google.android.exoplayer2.C;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
import java.io.UnsupportedEncodingException;
import java.util.Map;
import javax.realtime.MemoryArea;
import javolution.context.LogContext;
import javolution.context.ObjectFactory;
import javolution.io.UTF8StreamReader;
import javolution.lang.Reusable;
import javolution.text.CharArray;
import javolution.xml.sax.Attributes;
import kotlin.text.Typography;
import net.lingala.zip4j.util.InternalZipConstants;
import org.apache.http.cookie.ClientCookie;
import org.apache.http.protocol.HTTP;

/* loaded from: classes2.dex */
public final class XMLStreamReaderImpl implements XMLStreamReader, Reusable {
    static final int READER_BUFFER_CAPACITY = 4096;
    private static final int STATE_CDATA = 5;
    private static final int STATE_CHARACTERS = 1;
    private static final int STATE_CLOSE_TAGxELEM_NAME_READ = 15;
    private static final int STATE_CLOSE_TAGxREAD_ELEM_NAME = 14;
    private static final int STATE_COMMENT = 3;
    private static final int STATE_DTD = 16;
    private static final int STATE_DTD_INTERNAL = 17;
    private static final int STATE_MARKUP = 2;
    private static final int STATE_OPEN_TAGxATTR_NAME_READ = 9;
    private static final int STATE_OPEN_TAGxELEM_NAME_READ = 7;
    private static final int STATE_OPEN_TAGxEMPTY_TAG = 13;
    private static final int STATE_OPEN_TAGxEQUAL_READ = 10;
    private static final int STATE_OPEN_TAGxREAD_ATTR_NAME = 8;
    private static final int STATE_OPEN_TAGxREAD_ATTR_VALUE_DOUBLE_QUOTE = 12;
    private static final int STATE_OPEN_TAGxREAD_ATTR_VALUE_SIMPLE_QUOTE = 11;
    private static final int STATE_OPEN_TAGxREAD_ELEM_NAME = 6;
    private static final int STATE_PI = 4;
    private int _attrPrefixSep;
    private CharArray _attrQName;
    private CharArray _attrValue;
    private String _encoding;
    private int _index;
    private boolean _isEmpty;
    private int _nesting;
    ObjectFactory _objectFactory;
    private int _prefixSep;
    CharArray _prolog;
    private CharArray _qName;
    private int _readCount;
    private int _readIndex;
    private Reader _reader;
    private int _seqsCapacity;
    private int _seqsIndex;
    private int _start;
    private int _startOffset;
    private CharArray _text;
    static final String[] NAMES_OF_EVENTS = {"UNDEFINED", "START_ELEMENT", "END_ELEMENT", "PROCESSING_INSTRUCTIONS", "CHARACTERS", "COMMENT", "SPACE", "START_DOCUMENT", "END_DOCUMENT", "ENTITY_REFERENCE", "ATTRIBUTE", "DTD", "CDATA", "NAMESPACE", "NOTATION_DECLARATION", "ENTITY_DECLARATION"};
    private static final CharArray ENCODING = new CharArray("encoding");
    private static final CharArray VERSION = new CharArray(ClientCookie.VERSION_ATTR);
    private static final CharArray STANDALONE = new CharArray("standalone");
    private char[] _data = new char[8192];
    private int _eventType = 7;
    boolean _charactersPending = false;
    private int _state = 1;
    private final char[] _readBuffer = new char[4096];
    private final LocationImpl _location = new LocationImpl();
    private final NamespacesImpl _namespaces = new NamespacesImpl();
    private final AttributesImpl _attributes = new AttributesImpl(this._namespaces);
    private CharArray[] _elemStack = new CharArray[16];
    private final EntitiesImpl _entities = new EntitiesImpl();
    private final UTF8StreamReader _utf8StreamReader = new UTF8StreamReader();
    private final Runnable _createSeqLogic = new Runnable() { // from class: javolution.xml.stream.XMLStreamReaderImpl.1
        @Override // java.lang.Runnable
        public void run() {
            if (XMLStreamReaderImpl.this._seqsCapacity >= XMLStreamReaderImpl.this._seqs.length) {
                CharArray[] charArrayArr = new CharArray[XMLStreamReaderImpl.this._seqs.length * 2];
                System.arraycopy(XMLStreamReaderImpl.this._seqs, 0, charArrayArr, 0, XMLStreamReaderImpl.this._seqs.length);
                XMLStreamReaderImpl.this._seqs = charArrayArr;
            }
            XMLStreamReaderImpl.this._seqs[XMLStreamReaderImpl.access$108(XMLStreamReaderImpl.this)] = new CharArray();
        }
    };
    private CharArray[] _seqs = new CharArray[256];

    /* JADX INFO: Access modifiers changed from: private */
    /* loaded from: classes2.dex */
    public final class LocationImpl implements Location, Reusable {
        int _charactersRead;
        int _column;
        int _line;

        private LocationImpl() {
        }

        @Override // javolution.xml.stream.Location
        public int getCharacterOffset() {
            return this._charactersRead + XMLStreamReaderImpl.this._readIndex;
        }

        @Override // javolution.xml.stream.Location
        public int getColumnNumber() {
            return this._column + XMLStreamReaderImpl.this._readIndex;
        }

        @Override // javolution.xml.stream.Location
        public int getLineNumber() {
            return this._line + 1;
        }

        @Override // javolution.xml.stream.Location
        public String getPublicId() {
            return null;
        }

        @Override // javolution.xml.stream.Location
        public String getSystemId() {
            return null;
        }

        @Override // javolution.lang.Reusable
        public void reset() {
            this._line = 0;
            this._column = 0;
            this._charactersRead = 0;
        }

        public String toString() {
            return "Line " + getLineNumber() + ", Column " + getColumnNumber();
        }
    }

    static /* synthetic */ int access$108(XMLStreamReaderImpl xMLStreamReaderImpl) {
        int i = xMLStreamReaderImpl._seqsCapacity;
        xMLStreamReaderImpl._seqsCapacity = i + 1;
        return i;
    }

    private String detectEncoding(InputStream inputStream) throws XMLStreamException {
        try {
            int read = inputStream.read();
            if (read != -1) {
                if (read == 60) {
                    char[] cArr = this._readBuffer;
                    int i = this._startOffset;
                    this._startOffset = i + 1;
                    cArr[i] = Typography.less;
                    return "UTF-8";
                }
                try {
                    int read2 = inputStream.read();
                    if (read2 != -1) {
                        if (read == 0 && read2 == 60) {
                            char[] cArr2 = this._readBuffer;
                            int i2 = this._startOffset;
                            this._startOffset = i2 + 1;
                            cArr2[i2] = Typography.less;
                            return "UTF-16BE";
                        } else if (read == 60 && read2 == 0) {
                            char[] cArr3 = this._readBuffer;
                            int i3 = this._startOffset;
                            this._startOffset = i3 + 1;
                            cArr3[i3] = Typography.less;
                            return C.UTF16LE_NAME;
                        } else if (read == 255 && read2 == 254) {
                            return "UTF-16";
                        } else {
                            if (read == 254 && read2 == 255) {
                                return "UTF-16";
                            }
                            char[] cArr4 = this._readBuffer;
                            int i4 = this._startOffset;
                            this._startOffset = i4 + 1;
                            cArr4[i4] = (char) read;
                            int i5 = this._startOffset;
                            this._startOffset = i5 + 1;
                            cArr4[i5] = (char) read2;
                            return "UTF-8";
                        }
                    }
                    throw new XMLStreamException("Premature End-Of-File");
                } catch (IOException e) {
                    throw new XMLStreamException(e);
                }
            }
            throw new XMLStreamException("Premature End-Of-File");
        } catch (IOException e2) {
            throw new XMLStreamException(e2);
        }
    }

    private char handleEndOfLine(char c) throws XMLStreamException {
        if (c == '\r') {
            if (this._readIndex >= this._readCount) {
                reloadBuffer();
            }
            int i = this._readIndex;
            if (i < this._readCount && this._readBuffer[i] == '\n') {
                this._readIndex = i + 1;
            }
            c = '\n';
        }
        if (c == '\n') {
            this._location._line++;
            this._location._column = -this._readIndex;
        } else if (c == 0) {
            throw new XMLStreamException("Illegal XML character U+0000", this._location);
        }
        return c;
    }

    private IllegalStateException illegalState(String str) {
        return new IllegalStateException(str + " (" + NAMES_OF_EVENTS[this._eventType] + ")");
    }

    private void increaseDataBuffer() {
        MemoryArea.getMemoryArea(this).executeInArea(new Runnable() { // from class: javolution.xml.stream.XMLStreamReaderImpl.2
            @Override // java.lang.Runnable
            public void run() {
                char[] cArr = new char[XMLStreamReaderImpl.this._data.length * 2];
                LogContext.info(new CharArray("XMLStreamReaderImpl: Data buffer increased to " + cArr.length));
                System.arraycopy(XMLStreamReaderImpl.this._data, 0, cArr, 0, XMLStreamReaderImpl.this._data.length);
                XMLStreamReaderImpl.this._data = cArr;
            }
        });
    }

    private void increaseStack() {
        MemoryArea.getMemoryArea(this).executeInArea(new Runnable() { // from class: javolution.xml.stream.XMLStreamReaderImpl.3
            @Override // java.lang.Runnable
            public void run() {
                CharArray[] charArrayArr = new CharArray[XMLStreamReaderImpl.this._elemStack.length * 2];
                LogContext.info(new CharArray("XMLStreamReaderImpl: CharArray stack increased to " + charArrayArr.length));
                System.arraycopy(XMLStreamReaderImpl.this._elemStack, 0, charArrayArr, 0, XMLStreamReaderImpl.this._elemStack.length);
                XMLStreamReaderImpl.this._elemStack = charArrayArr;
            }
        });
    }

    private boolean isEndOfStream() throws XMLStreamException {
        if (this._readIndex >= this._readCount) {
            reloadBuffer();
        }
        if (this._readCount <= 0) {
            if (this._eventType != 8) {
                int i = this._index;
                int i2 = this._start;
                int i3 = i - i2;
                if (i3 <= 0) {
                    this._eventType = 8;
                    return true;
                }
                if (this._charactersPending) {
                    CharArray charArray = this._text;
                    charArray.setArray(this._data, charArray.offset(), this._text.length() + i3);
                } else {
                    this._text = newSeq(i2, i3);
                }
                this._start = this._index;
                this._eventType = 4;
                return true;
            }
            throw new XMLStreamException("End document has already been reached");
        }
        return false;
    }

    private static boolean isUTF8(Object obj) {
        return obj.equals("utf-8") || obj.equals("UTF-8") || obj.equals(HTTP.ASCII) || obj.equals("utf8") || obj.equals(InternalZipConstants.CHARSET_UTF8);
    }

    private static boolean isWhiteSpace(char c) {
        return c == ' ' || c == '\t' || c == '\r' || c == '\n';
    }

    private static boolean isXMLNS(CharArray charArray) {
        return charArray.length() == 5 && charArray.charAt(0) == 'x' && charArray.charAt(1) == 'm' && charArray.charAt(2) == 'l' && charArray.charAt(3) == 'n' && charArray.charAt(4) == 's';
    }

    private CharArray newSeq(int i, int i2) {
        CharArray newSeq2;
        int i3 = this._seqsIndex;
        if (i3 < this._seqsCapacity) {
            CharArray[] charArrayArr = this._seqs;
            this._seqsIndex = i3 + 1;
            newSeq2 = charArrayArr[i3];
        } else {
            newSeq2 = newSeq2();
        }
        return newSeq2.setArray(this._data, i, i2);
    }

    private CharArray newSeq2() {
        MemoryArea.getMemoryArea(this).executeInArea(this._createSeqLogic);
        CharArray[] charArrayArr = this._seqs;
        int i = this._seqsIndex;
        this._seqsIndex = i + 1;
        return charArrayArr[i];
    }

    private void processAttribute() throws XMLStreamException {
        if (this._attrPrefixSep < 0) {
            if (isXMLNS(this._attrQName)) {
                NamespacesImpl namespacesImpl = this._namespaces;
                namespacesImpl.setPrefix(namespacesImpl._defaultNsPrefix, this._attrValue);
                return;
            }
            AttributesImpl attributesImpl = this._attributes;
            CharArray charArray = this._attrQName;
            attributesImpl.addAttribute(charArray, null, charArray, this._attrValue);
            return;
        }
        int offset = this._attrQName.offset();
        int length = this._attrQName.length();
        CharArray newSeq = newSeq(offset, this._attrPrefixSep - offset);
        int i = this._attrPrefixSep;
        CharArray newSeq2 = newSeq(i + 1, ((offset + length) - i) - 1);
        if (isXMLNS(newSeq)) {
            this._namespaces.setPrefix(newSeq2, this._attrValue);
        } else {
            this._attributes.addAttribute(newSeq2, newSeq, this._attrQName, this._attrValue);
        }
    }

    private void processEndTag() throws XMLStreamException {
        if (this._qName.equals(this._elemStack[this._nesting])) {
            return;
        }
        throw new XMLStreamException("Unexpected end tag for " + ((Object) this._qName), this._location);
    }

    private void processStartTag() throws XMLStreamException {
        int i = this._nesting + 1;
        this._nesting = i;
        if (i >= this._elemStack.length) {
            increaseStack();
        }
        this._elemStack[this._nesting] = this._qName;
        this._namespaces.push();
    }

    private final CharArray readPrologAttribute(CharSequence charSequence) {
        int offsetOf;
        CharArray charArray = this._prolog;
        if (charArray != null && (offsetOf = charArray.offsetOf(charSequence)) >= 0) {
            int offset = this._prolog.offset() + this._prolog.length();
            int length = offsetOf + charSequence.length();
            char c = 0;
            int i = 0;
            while (length < offset) {
                int i2 = length + 1;
                char c2 = this._prolog.array()[length];
                if (c != 0) {
                    if (c != 1) {
                        if (c != 2) {
                            if (c == 3 && c2 == '\"') {
                                return newSeq(i, (i2 - i) - 1);
                            }
                        } else if (c2 == '\'') {
                            return newSeq(i, (i2 - i) - 1);
                        }
                    } else if (c2 == '\"') {
                        i = i2;
                        c = 3;
                    } else if (c2 == '\'') {
                        i = i2;
                        c = 2;
                    }
                } else if (c2 == '=') {
                    c = 1;
                }
                length = i2;
            }
        }
        return null;
    }

    private void reloadBuffer() throws XMLStreamException {
        this._location._column += this._readIndex;
        this._location._charactersRead += this._readIndex;
        this._readIndex = 0;
        try {
            this._readCount = this._reader.read(this._readBuffer, 0, this._readBuffer.length);
            if (this._readCount <= 0 && (this._nesting != 0 || this._state != 1)) {
                throw new XMLStreamException("Unexpected end of document", this._location);
            }
            while (this._index + this._readCount >= this._data.length) {
                increaseDataBuffer();
            }
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }

    private char replaceEntity() throws XMLStreamException {
        char c;
        char[] cArr;
        int i = this._state;
        if (i == 3 || i == 4 || i == 5) {
            return Typography.amp;
        }
        int i2 = this._index;
        char[] cArr2 = this._data;
        this._index = i2 + 1;
        cArr2[i2] = Typography.amp;
        do {
            if (this._readIndex >= this._readCount) {
                reloadBuffer();
            }
            char[] cArr3 = this._data;
            int i3 = this._index;
            this._index = i3 + 1;
            char[] cArr4 = this._readBuffer;
            int i4 = this._readIndex;
            this._readIndex = i4 + 1;
            c = cArr4[i4];
            cArr3[i3] = c;
            if (c == ';') {
                while (true) {
                    int maxLength = this._entities.getMaxLength() + i2;
                    cArr = this._data;
                    if (maxLength < cArr.length) {
                        break;
                    }
                    increaseDataBuffer();
                }
                this._index = i2 + this._entities.replaceEntity(cArr, i2, this._index - i2);
                if (this._readIndex >= this._readCount) {
                    reloadBuffer();
                }
                char[] cArr5 = this._readBuffer;
                int i5 = this._readIndex;
                this._readIndex = i5 + 1;
                char c2 = cArr5[i5];
                return c2 == '&' ? replaceEntity() : c2;
            }
        } while (c > ' ');
        throw new XMLStreamException("';' expected", this._location);
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public void close() throws XMLStreamException {
        ObjectFactory objectFactory = this._objectFactory;
        if (objectFactory != null) {
            objectFactory.recycle(this);
        } else {
            reset();
        }
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int getAttributeCount() {
        if (this._eventType == 1) {
            return this._attributes.getLength();
        }
        throw illegalState("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getAttributeLocalName(int i) {
        if (this._eventType == 1) {
            return this._attributes.getLocalName(i);
        }
        throw illegalState("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getAttributeNamespace(int i) {
        if (this._eventType == 1) {
            return this._namespaces.getNamespaceURINullAllowed(this._attributes.getPrefix(i));
        }
        throw illegalState("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getAttributePrefix(int i) {
        if (this._eventType == 1) {
            return this._attributes.getPrefix(i);
        }
        throw illegalState("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getAttributeType(int i) {
        if (this._eventType == 1) {
            return this._attributes.getType(i);
        }
        throw illegalState("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getAttributeValue(int i) {
        if (this._eventType == 1) {
            return this._attributes.getValue(i);
        }
        throw illegalState("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getAttributeValue(CharSequence charSequence, CharSequence charSequence2) {
        if (this._eventType == 1) {
            return charSequence == null ? this._attributes.getValue(charSequence2) : this._attributes.getValue(charSequence, charSequence2);
        }
        throw illegalState("Not a start element");
    }

    public Attributes getAttributes() {
        if (this._eventType == 1) {
            return this._attributes;
        }
        throw new IllegalStateException("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getCharacterEncodingScheme() {
        return readPrologAttribute(ENCODING);
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getElementText() throws XMLStreamException {
        if (getEventType() != 1) {
            throw new XMLStreamException("Parser must be on START_ELEMENT to read next text", getLocation());
        }
        CharArray charArray = null;
        while (true) {
            int next = next();
            if (next == 2) {
                return charArray != null ? charArray : newSeq(0, 0);
            } else if (next == 4) {
                if (charArray == null) {
                    charArray = getText();
                } else {
                    charArray.setArray(this._data, charArray.offset(), charArray.length() + getText().length());
                }
            } else if (next != 3 && next != 5) {
                if (next != 8) {
                    if (next == 1) {
                        throw new XMLStreamException("Element text content may not contain START_ELEMENT", getLocation());
                    }
                    throw new XMLStreamException("Unexpected event type " + NAMES_OF_EVENTS[next], getLocation());
                }
                throw new XMLStreamException("Unexpected end of document when reading element text content", getLocation());
            }
        }
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public String getEncoding() {
        return this._encoding;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int getEventType() {
        return this._eventType;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getLocalName() {
        int i = this._eventType;
        if (i == 1 || i == 2) {
            int i2 = this._prefixSep;
            return i2 < 0 ? this._qName : newSeq(i2 + 1, ((this._qName.offset() + this._qName.length()) - this._prefixSep) - 1);
        }
        throw illegalState("Not a start or end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public Location getLocation() {
        return this._location;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public NamespaceContext getNamespaceContext() {
        return this._namespaces;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int getNamespaceCount() {
        int i = this._eventType;
        if (i == 1 || i == 2) {
            return this._namespaces._namespacesCount[this._nesting];
        }
        throw illegalState("Not a start or end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getNamespacePrefix(int i) {
        int i2 = this._eventType;
        if (i2 == 1 || i2 == 2) {
            return this._namespaces._prefixes[i];
        }
        throw illegalState("Not a start or end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getNamespaceURI() {
        return this._namespaces.getNamespaceURINullAllowed(getPrefix());
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getNamespaceURI(int i) {
        int i2 = this._eventType;
        if (i2 == 1 || i2 == 2) {
            return this._namespaces._namespaces[i];
        }
        throw illegalState("Not a start or end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getNamespaceURI(CharSequence charSequence) {
        int i = this._eventType;
        if (i == 1 || i == 2) {
            return this._namespaces.getNamespaceURI(charSequence);
        }
        throw illegalState("Not a start or end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getPIData() {
        if (this._eventType == 3) {
            int offsetOf = this._text.offsetOf(' ') + 1;
            return newSeq(offsetOf, this._text.length() - offsetOf);
        }
        throw illegalState("Not a processing instruction");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getPITarget() {
        if (this._eventType == 3) {
            return newSeq(this._text.offset(), this._text.offsetOf(' '));
        }
        throw illegalState("Not a processing instruction");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getPrefix() {
        int i = this._eventType;
        if (i == 1 || i == 2) {
            if (this._prefixSep < 0) {
                return null;
            }
            int offset = this._qName.offset();
            return newSeq(offset, this._prefixSep - offset);
        }
        throw illegalState("Not a start or end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public Object getProperty(String str) throws IllegalArgumentException {
        if (str.equals(XMLInputFactory.IS_COALESCING)) {
            return new Boolean(true);
        }
        if (str.equals(XMLInputFactory.ENTITIES)) {
            return this._entities.getEntitiesMapping();
        }
        throw new IllegalArgumentException("Property: " + str + " not supported");
    }

    public CharArray getQName() {
        int i = this._eventType;
        if (i == 1 || i == 2) {
            return this._qName;
        }
        throw new IllegalStateException("Not a start element or an end element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getText() {
        int i = this._eventType;
        if (i == 4 || i == 5 || i == 11) {
            return this._text;
        }
        throw illegalState("Not a text event");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int getTextCharacters(int i, char[] cArr, int i2, int i3) throws XMLStreamException {
        CharArray text = getText();
        int min = Math.min(i3, text.length());
        System.arraycopy(text.array(), i + text.offset(), cArr, i2, min);
        return min;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public char[] getTextCharacters() {
        return getText().array();
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int getTextLength() {
        return getText().length();
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int getTextStart() {
        return getText().offset();
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public CharArray getVersion() {
        return readPrologAttribute(VERSION);
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean hasName() {
        int i = this._eventType;
        return i == 1 || i == 2;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean hasNext() throws XMLStreamException {
        return this._eventType != 8;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean hasText() {
        int i = this._eventType;
        return (i == 4 || i == 5 || i == 11) && this._text.length() > 0;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean isAttributeSpecified(int i) {
        if (this._eventType == 1) {
            return this._attributes.getValue(i) != null;
        }
        throw new IllegalStateException("Not a start element");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean isCharacters() {
        return this._eventType == 4;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean isEndElement() {
        return this._eventType == 2;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean isStandalone() {
        CharArray readPrologAttribute = readPrologAttribute(STANDALONE);
        if (readPrologAttribute != null) {
            return readPrologAttribute.equals("no");
        }
        return true;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean isStartElement() {
        return this._eventType == 1;
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean isWhiteSpace() {
        if (isCharacters()) {
            char[] array = this._text.array();
            int offset = this._text.offset();
            int offset2 = this._text.offset() + this._text.length();
            while (offset < offset2) {
                int i = offset + 1;
                if (!isWhiteSpace(array[offset])) {
                    return false;
                }
                offset = i;
            }
            return true;
        }
        return false;
    }

    /*  JADX ERROR: JadxRuntimeException in pass: BlockProcessor
        jadx.core.utils.exceptions.JadxRuntimeException: CFG modification limit reached, blocks count: 435
        	at jadx.core.dex.visitors.blocks.BlockProcessor.processBlocksTree(BlockProcessor.java:59)
        	at jadx.core.dex.visitors.blocks.BlockProcessor.visit(BlockProcessor.java:39)
        */
    @Override // javolution.xml.stream.XMLStreamReader
    public int next() throws javolution.xml.stream.XMLStreamException {
        /*
            Method dump skipped, instructions count: 1362
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: javolution.xml.stream.XMLStreamReaderImpl.next():int");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public int nextTag() throws XMLStreamException {
        int next;
        while (true) {
            next = next();
            if (next == 5 || next == 3 || next == 11 || (next == 4 && isWhiteSpace())) {
            }
        }
        if (next == 1 || next == 2) {
            return next;
        }
        throw new XMLStreamException("Tag expected (but found " + NAMES_OF_EVENTS[this._eventType] + ")");
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public void require(int i, CharSequence charSequence, CharSequence charSequence2) throws XMLStreamException {
        if (this._eventType != i) {
            throw new XMLStreamException("Expected event: " + NAMES_OF_EVENTS[i] + ", found event: " + NAMES_OF_EVENTS[this._eventType]);
        } else if (charSequence != null && !getNamespaceURI().equals((Object) charSequence)) {
            throw new XMLStreamException("Expected namespace URI: " + ((Object) charSequence) + ", found: " + ((Object) getNamespaceURI()));
        } else if (charSequence2 == null || getLocalName().equals((Object) charSequence2)) {
        } else {
            throw new XMLStreamException("Expected local name: " + ((Object) charSequence2) + ", found: " + ((Object) getLocalName()));
        }
    }

    @Override // javolution.lang.Reusable
    public void reset() {
        this._attributes.reset();
        this._attrPrefixSep = 0;
        this._attrQName = null;
        this._attrValue = null;
        this._attrQName = null;
        this._charactersPending = false;
        this._encoding = null;
        this._entities.reset();
        this._eventType = 7;
        this._index = 0;
        this._isEmpty = false;
        this._location.reset();
        this._namespaces.reset();
        this._objectFactory = null;
        this._prolog = null;
        this._readCount = 0;
        this._reader = null;
        this._nesting = 0;
        this._readIndex = 0;
        this._seqsIndex = 0;
        this._start = 0;
        this._startOffset = 0;
        this._state = 1;
        this._utf8StreamReader.reset();
    }

    public void setEntities(Map map) {
        this._entities.setEntitiesMapping(map);
    }

    public void setInput(InputStream inputStream) throws XMLStreamException {
        setInput(inputStream, detectEncoding(inputStream));
        CharArray characterEncodingScheme = getCharacterEncodingScheme();
        if (characterEncodingScheme == null || characterEncodingScheme.equals(this._encoding)) {
            return;
        }
        if (isUTF8(characterEncodingScheme) && isUTF8(this._encoding)) {
            return;
        }
        int i = this._readCount;
        reset();
        this._startOffset = i;
        setInput(inputStream, characterEncodingScheme.toString());
    }

    public void setInput(InputStream inputStream, String str) throws XMLStreamException {
        this._encoding = str;
        if (isUTF8(str)) {
            setInput(this._utf8StreamReader.setInput(inputStream));
            return;
        }
        try {
            setInput(new InputStreamReader(inputStream, str));
        } catch (UnsupportedEncodingException e) {
            throw new XMLStreamException(e);
        }
    }

    public void setInput(Reader reader) throws XMLStreamException {
        if (this._reader != null) {
            throw new IllegalStateException("Reader not closed or reset");
        }
        this._reader = reader;
        try {
            int read = reader.read(this._readBuffer, this._startOffset, this._readBuffer.length - this._startOffset);
            this._readCount = read >= 0 ? read + this._startOffset : this._startOffset;
            if (this._readCount >= 5 && this._readBuffer[0] == '<' && this._readBuffer[1] == '?' && this._readBuffer[2] == 'x' && this._readBuffer[3] == 'm' && this._readBuffer[4] == 'l' && this._readBuffer[5] == ' ') {
                next();
                this._prolog = getPIData();
                this._index = this._prolog.offset() + this._prolog.length();
                this._start = this._index;
                this._eventType = 7;
            }
        } catch (IOException e) {
            throw new XMLStreamException(e);
        }
    }

    @Override // javolution.xml.stream.XMLStreamReader
    public boolean standaloneSet() {
        return readPrologAttribute(STANDALONE) != null;
    }

    public String toString() {
        return "XMLStreamReader - State: " + NAMES_OF_EVENTS[this._eventType] + ", Location: " + this._location.toString();
    }
}
